package com.pucheng.bracelet.app.util;

import android.annotation.SuppressLint;
import android.content.Context;

import com.pucheng.bracelet.R;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class BandPeriodFormat {
//    public static String m6484a(Context context, BandPeriodTimeModel bandPeriodTimeModel, int i) {
//        int startHour = bandPeriodTimeModel.getStartHour();
//        int startMinute = bandPeriodTimeModel.getStartMinute();
//        int endHour = bandPeriodTimeModel.getEndHour();
//        int endMinute = bandPeriodTimeModel.getEndMinute();
//        if (startHour != endHour || startMinute != endMinute) {
//            if (i == 1) {
//                if (1440 - (((((endHour <= startHour ? endHour + 24 : endHour) - startHour) * 60) + endMinute) - startMinute) == 1) {
//                    return context.getString(R.string.all_day);
//                }
//            }
//            StringBuilder sb = new StringBuilder();
//            sb.append(timeFormat(context, startHour, startMinute));
//            String str = " ";
//            sb.append(str);
//            sb.append("-");
//            sb.append(str);
//            sb.append(timeFormat(context, endHour, endMinute));
//            return sb.toString();
//        } else if (i == 2) {
//            return context.getString(R.string.all_day);
//        } else {
//            return context.getString(R.string.close);
//        }
//    }

    public static String timeFormat(Context context, String timeStr) {
        String times[] = timeStr.split("[:]");
        int hours = Integer.parseInt(times[0]);
        int minutes = Integer.parseInt(times[1]);
        int bandTimeSystem = BandTimeSystemProvider.getBandTimeSystem();
        Calendar instance = Calendar.getInstance();
        instance.set(11, hours);
        instance.set(12, minutes);
        Date time = instance.getTime();
        String string = context.getString(R.string.hour_minute_a_format_24);
        if (bandTimeSystem == 0) {
            string = context.getString(R.string.hour_minute_a_format);
        }
        @SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat(string);
        return formatter.format(time);
    }
}
